package main.database.entity;

import javax.persistence.*;

/**
 * Created with IntelliJ IDEA.
 * User: Sknictik
 * Date: 28.11.13
 * Time: 3:57
 * To change this template use File | Settings | File Templates.
 */

//TODO set expenses of product as a part of product as a list. Reason for this is to not execute another query to get all expenses of some product you need to set inverse option to true so that you won't update id twice set this property on expenses list in products together with cascade = save-update

@Entity
@Table(name = "products")
public class Product extends MyEntity {

    @Id@GeneratedValue(strategy=GenerationType.AUTO)
    @Column(name = "id")
    private Long id;



    @Column(name = "name")
    String name;

    @ManyToOne
    @JoinColumn(name="id_category")
    private Category category;

    public Product() {
    }

    public Product(String name, Category cat)
    {
        this.name = name;
        this.category = cat;
    }

    public Product(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public Category getCategory() {
        return category;
    }

    @Override
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
}
